package handler

import (
	context2 "context"
	"gin/api/request"
	"gin/global/model"
	"gin/global/srv/product"
	"github.com/gin-gonic/gin"
	"net/http"
)

func PrputsList(context *gin.Context) {
	var P request.PrputsList
	if err := context.ShouldBind(&P); err != nil {
		context.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}
	list, err := model.ProConn.ProductList(context2.Background(), &product.ProductListRequest{
		Title: P.Title,
		Class: P.Clases,
		Page:  int64(P.Page),
	})
	if err != nil {
		context.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
		return
	}
	context.JSON(http.StatusOK, gin.H{"data": list})
}
